package com.hyh.main;

import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.rmi.RemoteException;

import com.hyh.gumballmachine.GumballMachine;
import com.hyh.monitor.GumballMachineMonitor;

public class GumballMachineTestDrive {

	public static void main(String[] args) {
		GumballMachine gumballMachine = new GumballMachine(10);
		gumballMachine.insertQuarter();
		gumballMachine.turnCrank();
		gumballMachine.dispense();
		
		GumballMachineMonitor gumballMachineMonitor;
		try {
			gumballMachineMonitor = new GumballMachineMonitor(gumballMachine);
			Naming.bind("gumballMachineMonitor", gumballMachineMonitor);
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (AlreadyBoundException e) {
			e.printStackTrace();
		}
	}
}
